package com.vates.reservas.web;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.vates.reservas.dominio.Cliente;
import com.vates.reservas.service.ClienteService;

/**
 * Handles and retrieves the main requests
 */
@Controller
@RequestMapping(value = "/cliente/busquedaPorId")
public class ClienteBusquedaPorIdController {

	protected static Logger logger = Logger.getLogger("controller");

	@Autowired
	private ClienteService clienteService;

	@RequestMapping(value = "/cliente/busquedaPorId", method = RequestMethod.GET)
	public String getClienteBusqueda() {

		return "cliente/busquedaPorId";
	}

	@RequestMapping(value = "/cliente/busquedaPorId", method = RequestMethod.POST)
	public @ResponseBody
	Cliente buscarPorId(@RequestParam(value = "id", required = true) long id,
			Model model) {

		Cliente cliente = clienteService.busquedaPorId(id);
		return cliente;
	}
}
